package org.smoozik.services.musictheory;

import org.smoozik.app.ihm.Constants;

public class Harmony {
	char flatOrSharp;
	int nb;

	public Harmony(char flatOrSharp, int nb) {
		super();
		this.flatOrSharp = flatOrSharp;
		this.nb = nb;
	}

	public Harmony() {
		this(Constants.SHARP, 0);
	}

	public char getFlatOrSharp() {
		return flatOrSharp;
	}

	public void setFlatOrSharp(char flatOrSharp) {
		this.flatOrSharp = flatOrSharp;
	}

	public int getNb() {
		return nb;
	}

	public void setNb(int nb) {
		this.nb = nb;
	}

	public String toString() {
		String name = "";

		if (nb == 0) {
			name = "C";
		} else if (flatOrSharp != Constants.SHARP
				&& flatOrSharp != Constants.FLAT) {
			name = "UNKNOWN";
		} else if (nb > 7 || nb < 0) {
			name = "UNKNOWN";
		} else {
			if (Constants.SHARP == flatOrSharp) {
				name = Constants.SHARP_HARMONY_NAMES[nb - 1];
			} else {

				name = Constants.FLAT_HARMONY_NAMES[nb - 1];
			}
		}

		return name;
	}
}
